exports.goodsTable = [
  /**
   * 商品表
   */
  {
    sql: `
    CREATE TABLE IF NOT EXISTS goods (
      id INT AUTO_INCREMENT PRIMARY KEY,
      created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
      goods_name VARCHAR(60) NOT NULL,
      sub_name VARCHAR(30) NOT NULL,
      image VARCHAR(255) NOT NULL,
      banner JSON,
      video VARCHAR(255),
      is_recommend INT NOT NULL DEFAULT 0 CHECK (is_recommend IN (0, 1)),
      is_new INT NOT NULL DEFAULT 0 CHECK (is_new IN (0, 1)),
      is_hot INT NOT NULL DEFAULT 0 CHECK (is_hot IN (0, 1)),
      is_on_sale INT NOT NULL DEFAULT 0 CHECK (is_on_sale IN (0, 1)),
      is_delete INT NOT NULL DEFAULT 0 CHECK (is_delete IN (0, 1)),
      store_id INT NOT NULL,
      category_id INT DEFAULT -1,
      brand_id INT DEFAULT -1,
      store_category_id INT DEFAULT -1,
      FOREIGN KEY (store_id) REFERENCES store(id),
      FOREIGN KEY (category_id) REFERENCES goods_category(id),
      FOREIGN KEY (brand_id) REFERENCES goods_brand(id),
      FOREIGN KEY (store_category_id) REFERENCES store_category(id),
      price DECIMAL(10, 2) NOT NULL,
      stock INT NOT NULL,
      desc_content TEXT NOT NULL,
      specification_name VARCHAR(255) NOT NULL,
      size_name VARCHAR(255),
      consignment_date VARCHAR(50) NOT NULL
  )
  `,
    name: '商品goods'
  },
  /**
   * 商品分类表
  */
  {
    sql:
      `
        CREATE TABLE IF NOT EXISTS goods_category (
          id INT AUTO_INCREMENT PRIMARY KEY,
          created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
          name VARCHAR(100) NOT NULL,
          desc_content TEXT,
          image VARCHAR(255) NOT NULL,
          url VARCHAR(255) NOT NULL,
          parent_id INT DEFAULT -1,
          FOREIGN KEY (parent_id) REFERENCES goods_category(id),
          sort INT NOT NULL,
          is_show INT NOT NULL DEFAULT 0 CHECK (is_show IN (0, 1)),
          is_delete INT NOT NULL DEFAULT 0 CHECK (is_delete IN (0, 1))
        )
      `,
    name: '商品分类goods_category'
  },
  /**
   * 商品品牌表
  */
  {
    sql:
      `
        CREATE TABLE IF NOT EXISTS goods_brand (
        id INT AUTO_INCREMENT PRIMARY KEY,
        created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
        name VARCHAR(100) NOT NULL,
        logo VARCHAR(255) NOT NULL,
        desc_content TEXT,
        url VARCHAR(255) NOT NULL,
        sort INT NOT NULL,
        is_show INT NOT NULL DEFAULT 0 CHECK (is_show IN (0, 1)),
        is_delete INT NOT NULL DEFAULT 0 CHECK (is_delete IN (0, 1))
        )
      `,
    name: '商品品牌goods_brand'
  },
  /**
   * 店铺商品分类表
  */
  {
    sql:
      `
        CREATE TABLE IF NOT EXISTS store_category(
        id INT AUTO_INCREMENT PRIMARY KEY,
        created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
        name VARCHAR(100) NOT NULL,
        desc_content TEXT,
        image VARCHAR(255) NOT NULL,
        parent_id INT DEFAULT -1,
        url VARCHAR(255) NOT NULL,
        FOREIGN KEY (parent_id) REFERENCES store_category(id),
        sort INT NOT NULL,
        is_show INT NOT NULL DEFAULT 0 CHECK (is_show IN (0, 1))
        )
      `,
    name: '店铺商品分类store_category'
  },
]